---
category: Level 1 — Basic
created: '2020-05-03'
keywords: check code run browser, detect browser
title: Check if the code is running in the browser
---

We can detect if the current code is running in the browser by checking the existence of `window` and `document` objects:

```js
const isBrowser = typeof window === 'object' && typeof document === 'object';
```

## See also

-   [Detect internet explorer browser](https://phuoc.ng/collection/html-dom/detect-internet-explorer-browser/)
-   [Detect mac os browser](https://phuoc.ng/collection/html-dom/detect-mac-os-browser/)
-   [Detect mobile browsers](https://phuoc.ng/collection/html-dom/detect-mobile-browsers/)
